﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Human
    {

        Man Father;
        Women Mother;
        public string Name;
        public List<Human> Children = new List<Human>();
        public Human(Man father,Women mother,string name)
        {
            Father = father;
            Mother = mother;
            Name = name;
            if (father == null || mother == null)
            {
                father.Children.Add(this);
                mother.Children.Add(this);
            }
        }

        public static string GetRandomName()
        {
            string[] names = new string[3];
            Random a = new Random();
            names[0] = "Sasha";
            names[1] = "Valya";
            names[2] = "Eugene";
            return names[a.Next(0,2)];
        }

        public virtual string MyInfo()
        {
            string fat;
            string mom;
            string info;
            if (Father == null)
            {
                fat = "У меня нет отца";
            }
            else
            {
                fat = "Мой отец " + Father.Name;
            }
            if (Mother == null)
            {
                mom = "У меня нет матери";
            }
            else
            {
                mom = "Моя мать " + Mother.Name;
            }
            if (Children.Count > 0)
            {
                switch (Children.Count)
                {
                    case 1:
                        info = "Меня зовут " + Name + ". " + fat + ". " + mom + "У меня 1 ребёнок. Его имя: " + Children[0].Name;
                        break;
                    case 2:
                        info = "Меня зовут " + Name + ". " + fat + ". " + mom + "У меня 2 ребёнка. Их имена: " + Children[0].Name + " и " + Children[1].Name;
                        break;
                    case 3:
                        info = "Меня зовут " + Name + ". " + fat + ". " + mom + "У меня 3 ребёнка. Их имена: " + Children[0].Name + ", " + Children[1].Name + " и " + Children[2].Name;
                        break;
                    case 4:
                        info = "Меня зовут " + Name + ". " + fat + ". " + mom + "У меня 3 ребёнка. Их имена: " + Children[0].Name + ", " + Children[1].Name + ", " + Children[2].Name +" и " + Children[3].Name;
                        break;
                    default:
                        info = "Меня зовут " + Name + ". " + fat + ". " + mom + "У меня " + Children.Count + " детей. Их имена: ";
                        for (int i = 0; i < Children.Count; i++)
                        {
                            if (i == Children.Count)
                            {
                                info += Children[i].Name;
                            }
                            else
                            {
                                info += Children[i].Name + ", ";
                            }
                        }
                        info += ".";
                        break;
                }
            }
            else
            {
                info = "Меня зовут " + Name + ". " + fat + ". " + mom + ".";
            }
            return info;
        }
    }
    class Man : Human
    {
        public List<Car> LikeCars = new List<Car>();
        new public static string GetRandomName()
        {
            string[] MNames = new string[5];
            Random a = new Random();
            MNames[0] = "Alexei";
            MNames[1] = "Vanya";
            MNames[2] = "Vasya";
            MNames[3] = "Igor";
            MNames[4] = "Anatolii";
            return MNames[a.Next(0, 4)];
        }

        public void AddLikeCars(Car car)
        {
            LikeCars.Add(car);
        }

        public void AddLikeCars(Car car, Car car2)
        {
            LikeCars.Add(car);
            LikeCars.Add(car2);
        }

        public void AddLikeCars(Car car, Car car2, Car car3)
        {
            LikeCars.Add(car);
            LikeCars.Add(car2);
            LikeCars.Add(car3);
        }

        public Man(Man father, Women mother, string name)
            : base(father, mother, name)
        {

        }
        public override string MyInfo()
        {
            string info = base.MyInfo() + " Я мужского пола.";
            if (LikeCars.Count > 0)
            {
                switch (LikeCars.Count)
                {
                    case 1:
                        info += " У меня 1 любимая машина. Её название: " + LikeCars[0].Name;
                        break;
                    case 2:
                        info += " У меня 2 любимые машины. Их названия: " + LikeCars[0].Name + ", " + LikeCars[1].Name;
                        break;
                    case 3:
                        info += " У меня 3 любимые машины. Их названия: " + LikeCars[0].Name + ", " + LikeCars[1].Name + ", " + LikeCars[2].Name;
                        break;
                    case 4:
                        info += " У меня 4 любимые машины. Их названия: " + LikeCars[0].Name + ", " + LikeCars[1].Name + ", " + LikeCars[2].Name + ", " + LikeCars[3].Name;
                        break;
                    default:
                        info += " У меня " + LikeCars.Count + " любимых машин. Их названия: ";
                        for (int i = 0; i < LikeCars.Count; i++)
                        {
                            if (i == LikeCars.Count)
                            {
                                info += LikeCars[i].Name;
                            }
                            else
                            {
                                info += LikeCars[i].Name + ", ";
                            }
                        }
                        info += ".";
                        break;
                }
            }
            else
            {
            }
            return info;
        }
    }
    class Women : Human
    {
        public List<string> LikeDinners = new List<string>();
        new public static string GetRandomName()
        {
            string[] WNames = new string[5];
            Random a = new Random();
            WNames[0] = "Anya";
            WNames[1] = "Maria";
            WNames[2] = "Margarita";
            WNames[3] = "Lena";
            WNames[4] = "Alena";
            return WNames[a.Next(0, 4)];
        }
        public Women(Man father, Women mother, string name)
            : base(father, mother, name)
        {

        }

        public void AddLikeCars(string dinner1)
        {
            LikeDinners.Add(dinner1);
        }

        public void AddLikeCars(string dinner1, string dinner2)
        {
            LikeDinners.Add(dinner1);
            LikeDinners.Add(dinner2);
        }

        public void AddLikeCars(string dinner1, string dinner2, string dinner3)
        {
            LikeDinners.Add(dinner1);
            LikeDinners.Add(dinner2);
            LikeDinners.Add(dinner3);
        }

        public override string MyInfo()
        {
            string info = base.MyInfo() + " Я женского пола.";
            if (LikeDinners.Count > 0)
            {
                switch (LikeDinners.Count)
                {
                    case 1:
                        info += " У меня 1 любимое блюдо. Его название: " + LikeDinners[0];
                        break;
                    case 2:
                        info += " У меня 2 любимых блюда. Их названия: " + LikeDinners[0] + ", " + LikeDinners[1];
                        break;
                    case 3:
                        info += " У меня 3 любимых блюда. Их названия: " + LikeDinners[0] + ", " + LikeDinners[1] + ", " + LikeDinners[2];
                        break;
                    case 4:
                        info += " У меня 4 любимых блюда. Их названия: " + LikeDinners[0] + ", " + LikeDinners[1] + ", " + LikeDinners[2] + ", " + LikeDinners[3];
                        break;
                    default:
                        info += " У меня " + LikeDinners.Count + " любимых блюд. Их названия: ";
                        for (int i = 0; i < LikeDinners.Count; i++)
                        {
                            if (i == LikeDinners.Count)
                            {
                                info += LikeDinners[i];
                            }
                            else
                            {
                                info += LikeDinners[i] + ", ";
                            }
                        }
                        info += ".";
                        break;
                }
            }
            else
            {
            }
            return info;
        }
    }

    class Car
    {
        public string Name;
        public int Price;
        public Car(string name,int price)
        {
            Name = name;
            Price = price;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Man adam = new Man(null, null, "Adam");
            Console.WriteLine(adam.MyInfo());
            Women eva = new Women(null, null, "Eva");
            Console.WriteLine(eva.MyInfo());
            Man kain = new Man(adam, eva, "Kain");
            Console.WriteLine(kain.MyInfo());
            Women avan = new Women(adam, eva, "Avan");
            Console.WriteLine(avan.MyInfo());
            Man enoch = new Man(kain, avan, "Enoch");
            Console.WriteLine(enoch.MyInfo());
            Console.ReadLine();
        }
    }
}
